package com.readbook.service;

import com.readbook.dao.XsycDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.*;

@Service
public class XsycService {
    @Autowired
    private XsycDao xsycDao;

    public List<Map<String, Object>> Search_bookxsyc(Map<String, Object> gmap) {
        List<Map<String, Object>> list1 = xsycDao.Search_bookxsyc(gmap);
        for (int i = 0; i < list1.size(); i++) {
            Map<String, Object> maps = list1.get(i);
            String ycid = maps.get("YCID").toString();
            List<Map<String, Object>> list2 = new ArrayList<>();
            list2 = xsycDao.getPictureByYcid(ycid);
            maps.put("photos", list2);
        }
        return list1;
    }

    public int setshzt_xsyc(Map<String, Object> gmap) {
        return xsycDao.setshzt_xsyc(gmap);
    }

    public int del_bookxsyc(Map<String, Object> gmap) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        gmap.put("jlscsj", df.format(new Date()));
        gmap.put("jlsczt", "1");
        return xsycDao.del_bookxsyc(gmap);
    }

}


